use std::collections::HashMap;

use container_core::workflow::{SimpleWorkflowEngine, WorkflowDocumentJsonReader};
use model_graph_types::container::workflow::{
    WorkflowDocumentReadeOptions, WorkflowDocumentReader, WorkflowEngine,
    WorkflowEngineCompileOptions, WorkflowEngineRunOptions,
};
use serde::{Deserialize, Serialize};

use super::{RunArguments, RunResponse};

pub async fn run_by_identifier(
    identifier: &String,
    args: RunArguments,
) -> anyhow::Result<RunResponse> {
    let document = WorkflowDocumentJsonReader::default()
        .read_from_json_file(
            &String::from("/Users/jinisu/rrg01/workflow.json"),
            WorkflowDocumentReadeOptions::default(),
        )
        .await?;

    let args = HashMap::new();

    let res = SimpleWorkflowEngine::default()
        .run_with_document(
            document,
            args,
            WorkflowEngineCompileOptions::default(),
            WorkflowEngineRunOptions::default(),
        )
        .await;

    Ok(RunResponse {
        workflow_identifier: identifier.clone(),
        task_id: String::from(""),
    })
}
